const initState = {
  list: [],
};

const reducer = (state = initState, action) => {
  switch (action.type) {
    case "add":
      return {
        ...state,
        list: [...state.list, action.payload],
      };
    case "remove":
      return {
        ...state,
        list: state.list.filter((item) => item.id !== action.id),
      };
    case "zzz":
      console.log("zzz");
      return state;
    case "load":
      return {
        ...state,
        list: action.payload,
      };
    default:
      return state;
  }
};

export default reducer;
